package com.hmall.order.mq;

import com.hmall.order.constans.OrderMqConstants;
import com.hmall.order.web.OrderController;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: ahcfl
 * @Date: 2021年07月31日 21:41
 * @Description:
 */
@Component
public class OrderListener {

    @Autowired
    private OrderController orderController;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = OrderMqConstants.DELAY_QUEUE_NAME),
            exchange = @Exchange(name = OrderMqConstants.EXCHANGE_NAME, delayed = "true"),
            key = OrderMqConstants.DELAY_KEY
    ))
    public void listenOrderDelay(String orderId) {
        System.err.println("开始接收处理延时订单消息~~~：" + orderId);
        orderController.handleOrder(new Long(orderId));
    }


}
